<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('ai_log', function (Blueprint $table) {
            $table->comment('请求日志');
            $table->increments('id');
            $table->integer('app_id');
            $table->longText('prompt');
            $table->json('images');
            $table->tinyInteger('stream');
            $table->string('model')->default('');
            $table->integer('image_token')->default(new \Illuminate\Database\Query\Expression('0'));
            $table->integer('text_token')->default(new \Illuminate\Database\Query\Expression('0'));
            $table->json('params')->comment('完整请求参数');
            $table->json('image_response');
            $table->json('text_response');
            $table->string('image_request_id')->default('');
            $table->string('text_request_id')->default('');
            $table->string('session_id')->default('');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('ai_log');
    }
};
